﻿using System;

namespace Course1
{
    public class Student1
    {
        public int Age { get; set; }
        public Student1()
        {
            Age = 20;
        }
    }
   
    public struct Student2
    {
        public int Age { get; set; }
     
    }
    /// <summary>
    /// 值类型和引用类型的值传递问题
    /// 1.传递方式都是值复制
    /// 2.方式相同结果不一定，关键看传过去的是什么（是值还是地址）
    /// 值类型：所有的结构体和基本类型
    /// 引用类型：所有的class类型
    /// 了解ref参数，out参数，in参数，params参数
    /// </summary>
    internal class Example7
    {
        public void Change(Student1 student)
        {
            student.Age = student.Age + 1;
        }

        public void Change(Student2 student)
        {
            student.Age = student.Age + 1;
        }

        public void Change(ref Student2 student)
        {
            student.Age = student.Age + 1;
        }

        public void Out(out int a, out int b)
        {
            a = 20;
            b = 90;
        }

        public void DynamicArguments(params int[] list)
        {
            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }

        public void Test()
        {
            Student1 studen1 = new Student1();
            Change(studen1);
            Student2 student2 = new Student2();
            Change(student2);
            Student2 student3 = new Student2();
            Change(ref student3);
        }
    }
}
